/**
 * 物料管理数据model
 */
import {getPageManageList,saveObj,deleteObj,getInfo} from 'api/entryManageApi';

const entryManage = {
    state: {
        entryManagePageData:[],
        page: {
            currentPage: 1,
            pageSize: 5,
            total: 0
        },
        queryPara:{
            name: '',
        }
    },
    mutations: {
        loadEntryManageMut(state, obj){
            if (obj.rows !== '') {
                state.entryManagePageData = obj.rows;
                state.page.currentPage = obj.currentPage;
                state.page.pageSize = obj.pageSize;
                state.page.total = obj.total;
            }
        },
        setEntryManageQueryPrams(state, obj){
            state.queryPara = obj;
        }

    },
    actions: {
        /*获取分页列表*/
        getEntryManagePageListAct (context, para) {
            return getPageManageList(para).then(res => {
                context.commit("loadEntryManageMut",res.data);
            });
        },
        /*新增/编辑*/
        saveEntryAct (context, para) {
            return saveObj(para).then(res=>{
                return res.data;
            });
        },
        /*删除*/
        deleteEntryAct (context, para) {
            return deleteObj(para).then(res=>{
                return res.data;
            });
        },
        /*获取分页列表*/
        getEntryInfo (context, para) {
            return getInfo(para).then(res => {
                return res.data;
            });
        },

    }
};

export default entryManage;
